The padding
property adds space around the content of a view, mirroring the behavior of SwiftUI’s padding
modifier. It helps separate a view from surrounding elements and improve layout clarity.
You can specify padding in multiple ways:
Applies the system default padding on all sides.
Applies the same number of points of padding to all edges.
Specify individual edges or edge groups.
Key | Description |
---|---|
horizontal |
Padding for both leading and trailing |
vertical |
Padding for both top and bottom |
leading |
Padding on the leading edge (LTR: left) |
trailing |
Padding on the trailing edge (LTR: right) |
top |
Padding on the top |
bottom |
Padding on the bottom |
Each value can be a number or true
. When set to true
, it applies the default system padding for that edge.
true
for specific edges:horizontal
/vertical
and leading
/trailing
can be combined. The more specific key (like leading
) overrides the group key (like horizontal
) if both are provided.